[hizbId]-21b0047c6e5feac3.js.map 6.0 KB

1
  1. {"version":3,"file":"static/chunks/pages/hizb/[hizbId]-21b0047c6e5feac3.js","mappings":"wFACKA,OAAOC,SAAWD,OAAOC,UAAY,IAAIC,KAAK,CAC7C,iBACA,WACE,OAAO,EAAQ,W,kNCiHvB,UApF0C,Y,IAAGC,EAAQ,EAARA,SAAUC,EAAU,EAAVA,WACjCC,GAAAA,EAAAA,EAAAA,GAAe,UAA3BC,EAAYD,EAAZC,EAAGC,EAASF,EAATE,KAETC,GACEC,EAAAA,EAAAA,aADFD,MAASE,OAGX,GAAIP,EAAU,OAAO,SAACQ,EAAAA,QAAK,CAACC,WAAY,MAExC,IAAMC,GAAOC,EAAAA,EAAAA,IAAqBC,OAAOL,IACzC,OACE,sB,WACE,SAACM,EAAAA,EAAc,CACbC,MAAO,GAAgBC,OAAbZ,EAAE,QAAQ,KAA2C,QAAxCY,EAAAA,EAAAA,IAAkBH,OAAOL,GAASH,IACzDY,aAAaC,EAAAA,EAAAA,IAA4BhB,GACzCiB,WAAWC,EAAAA,EAAAA,IAAgBf,EAAMM,GACjCU,oBAAoBC,EAAAA,EAAAA,IAAsBX,MAE5C,SAACY,EAAAA,EAAW,CACVC,YAAatB,EACbuB,GAAIC,OAAOlB,GACXmB,oBAAqBC,EAAAA,GAAAA,a","sources":["webpack://_N_E/?16e4","webpack://_N_E/./src/pages/hizb/[hizbId]/index.tsx"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/hizb/[hizbId]\",\n function () {\n return require(\"private-next-pages/hizb/[hizbId]/index.tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/hizb/[hizbId]\"])\n });\n }\n ","import React from 'react';\n\nimport { GetStaticPaths, GetStaticProps, NextPage } from 'next';\nimport { useRouter } from 'next/router';\nimport useTranslation from 'next-translate/useTranslation';\n\nimport { getHizbVerses, getPagesLookup } from '@/api';\nimport NextSeoWrapper from '@/components/NextSeoWrapper';\nimport QuranReader from '@/components/QuranReader';\nimport Error from '@/pages/_error';\nimport { getQuranReaderStylesInitialState } from '@/redux/defaultSettings/util';\nimport { getDefaultWordFields, getMushafId } from '@/utils/api';\nimport { getAllChaptersData } from '@/utils/chapter';\nimport { getLanguageAlternates, toLocalizedNumber } from '@/utils/locale';\nimport { getCanonicalUrl, getHizbNavigationUrl } from '@/utils/navigation';\nimport { formatStringNumber } from '@/utils/number';\nimport { getPageOrJuzMetaDescription } from '@/utils/seo';\nimport {\n REVALIDATION_PERIOD_ON_ERROR_SECONDS,\n ONE_WEEK_REVALIDATION_PERIOD_SECONDS,\n} from '@/utils/staticPageGeneration';\nimport { isValidHizbId } from '@/utils/validator';\nimport { generateVerseKeysBetweenTwoVerseKeys } from '@/utils/verseKeys';\nimport { VersesResponse } from 'types/ApiResponses';\nimport ChaptersData from 'types/ChaptersData';\nimport { QuranReaderDataType } from 'types/QuranReader';\n\ninterface HizbPageProps {\n hizbVerses?: VersesResponse;\n hasError?: boolean;\n chaptersData: ChaptersData;\n}\n\nconst HizbPage: NextPage<HizbPageProps> = ({ hasError, hizbVerses }) => {\n const { t, lang } = useTranslation('common');\n const {\n query: { hizbId },\n } = useRouter();\n\n if (hasError) return <Error statusCode={500} />;\n\n const path = getHizbNavigationUrl(Number(hizbId));\n return (\n <>\n <NextSeoWrapper\n title={`${t('hizb')} ${toLocalizedNumber(Number(hizbId), lang)}`}\n description={getPageOrJuzMetaDescription(hizbVerses)}\n canonical={getCanonicalUrl(lang, path)}\n languageAlternates={getLanguageAlternates(path)}\n />\n <QuranReader\n initialData={hizbVerses}\n id={String(hizbId)}\n quranReaderDataType={QuranReaderDataType.Hizb}\n />\n </>\n );\n};\n\n// eslint-disable-next-line react-func/max-lines-per-function\nexport const getStaticProps: GetStaticProps = async ({ params, locale }) => {\n let hizbId = String(params.hizbId);\n // we need to validate the hizbId first to save calling BE since we haven't set the valid paths inside getStaticPaths to avoid pre-rendering them at build time.\n if (!isValidHizbId(hizbId)) return { notFound: true };\n\n const chaptersData = await getAllChaptersData(locale);\n hizbId = formatStringNumber(hizbId);\n\n const defaultMushafId = getMushafId(\n getQuranReaderStylesInitialState(locale).quranFont,\n getQuranReaderStylesInitialState(locale).mushafLines,\n ).mushaf;\n\n try {\n const pagesLookupResponse = await getPagesLookup({\n hizbNumber: Number(hizbId),\n mushaf: defaultMushafId,\n });\n const firstPageOfHizb = Object.keys(pagesLookupResponse.pages)[0];\n const firstPageOfHizbLookup = pagesLookupResponse.pages[firstPageOfHizb];\n const numberOfVerses = generateVerseKeysBetweenTwoVerseKeys(\n chaptersData,\n pagesLookupResponse.lookupRange.from,\n pagesLookupResponse.lookupRange.to,\n ).length;\n const hizbVersesResponse = await getHizbVerses(hizbId, locale, {\n ...getDefaultWordFields(getQuranReaderStylesInitialState(locale).quranFont),\n mushaf: defaultMushafId,\n perPage: 'all',\n from: firstPageOfHizbLookup.from,\n to: firstPageOfHizbLookup.to,\n });\n const metaData = { numberOfVerses };\n hizbVersesResponse.metaData = metaData;\n hizbVersesResponse.pagesLookup = pagesLookupResponse;\n return {\n props: {\n chaptersData,\n hizbVerses: hizbVersesResponse,\n },\n revalidate: ONE_WEEK_REVALIDATION_PERIOD_SECONDS, // verses will be generated at runtime if not found in the cache, then cached for subsequent requests for 7 days.\n };\n } catch (error) {\n return {\n props: {\n hasError: true,\n },\n revalidate: REVALIDATION_PERIOD_ON_ERROR_SECONDS, // 35 seconds will be enough time before we re-try generating the page again.\n };\n }\n};\n\nexport const getStaticPaths: GetStaticPaths = async () => ({\n paths: [], // no pre-rendered hizbs at build time.\n fallback: 'blocking', // will server-render pages on-demand if the path doesn't exist.\n});\n\nexport default HizbPage;\n"],"names":["window","__NEXT_P","push","hasError","hizbVerses","useTranslation","t","lang","query","useRouter","hizbId","Error","statusCode","path","getHizbNavigationUrl","Number","NextSeoWrapper","title","toLocalizedNumber","description","getPageOrJuzMetaDescription","canonical","getCanonicalUrl","languageAlternates","getLanguageAlternates","QuranReader","initialData","id","String","quranReaderDataType","QuranReaderDataType"],"sourceRoot":""}